#ifndef __CAT1_H
#define __CAT1_H
#include "ddl.h"

//开关机
#define		PWRKEY_PORT			GpioPortB
#define 	     PWRKEY_PIN			GpioPin14

//通电
#define		TPS_EN_PORT			GpioPortD
#define		TPS_EN_PIN			GpioPin7

//低功耗相关   拉低MAIN_DTR_PIN可以唤醒cat1
#define        MAIN_DTR_PORT		GpioPortB
#define        MAIN_DTR_PIN	     GpioPin12
#define        MAIN_RI_PORT	     GpioPortB      //MAIN_RI 用于接收CAT1模组的唤醒信号
#define        MAIN_RI_PIN	     GpioPin0      //MAIN_RI 用于接收CAT1模组的唤醒信号

#define        RESET_PORT	     GpioPortB      //reset引脚
#define        RESET_PIN	          GpioPin13


#define		ON					1
#define		OFF					0

#define   SEND_MAX_LEN	     256

#define   REV_OK		0	//接收完成标志
#define   REV_WAIT	     1	//接收未完成标志

#define 	CLIENT_IDX		0
#define 	MSGID			1
#define	QOS				1
#define	RETAIN			1

#define   OPENADDRESS     "10427644.non-nb.ctwing.cn"
#define   OPENPORT        1883
//DEVICE_ID: "17222628QG_001"	,
#define 	DEVICE_ID			"17222628864784074801055"		
#define 	CONN_ADDRESS 		"10427644.non-nb.ctwing.cn:1883"
#define   USERNAME            "pm1231"
// uAnhXCLRdODn-krPedNRsMm-qSD53LVMcKhYDphTNX0
#define	PASSWORD			"uAnhXCLRdODn-krPedNRsMm-qSD53LVMcKhYDphTNX0"

void CAT1_PWRKEY_init();

void CAT1_TPS_init();

void CAT1_TPS_set(uint8_t state);

void CAT1_MAIN_DTR_init();

void CAT1_MAIN_DTR_set(uint8_t state);

void CAT1_MAIN_RI_init();

void CAT1_RESET_init();

void CAT1_RESET_set(uint8_t state);

uint8_t CAT1_PWRKEY_set(uint8_t state);

uint8_t NT26K_Connect_MQTT(void);

uint8_t NT26K_Subscribe(void);

unsigned int sendCommand(char *Command, char *Response, unsigned long Timeout, unsigned char Retry);

unsigned int sendCommandDetail(char *Command, char *Response, char *resultResp, unsigned long Timeout, unsigned char Retry);

unsigned char* NT26K_GetData(unsigned short timeOut);

void Resolve_Rev(unsigned char *cmd);

void NT26K_selfTest(void);

void NT26K_ConfigureDefault(void);     //配置RI

uint8_t NT26K_SendData(char* topic, char* buf);

uint8_t NT26K_sendDeviceInfo(void);

uint8_t NT26K_sendDeviceSignal(void);

uint8_t set_CAT1_enter_low_power(void);

uint8_t NT26K_getNetworkBand(char *band_info);


#endif


